<template>
  <div class="login">
    <div class="login-title">
      <span>开口说英语</span>
    </div>
    <div class="login-content">
      <el-card class="login-content-card">
        <div class="login-content-head">
          <el-image>
            <div slot="error" class="image-slot">
              <i class="el-icon-picture-outline" />
            </div>
          </el-image>
        </div>
        <div class="login-content-left">
          <!-- v-model="activeName" @tab-click="handleClick" -->
          <el-tabs class="login-content-left-tabs">
            <el-tab-pane class="login-content-left-tabs-pane" label="密码登入" name="first" />
            &nbsp;         &nbsp; &nbsp; &nbsp; &nbsp;
            <el-tab-pane class="login-content-left-tabs-pane" label="验证码登入" name="second" />
            <!-- <el-tab-pane class="login-content-left-tabs-pane" label="二维码登入" name="thress" /> -->
          </el-tabs>
          <!--  -->
          <el-form ref="loginForm" :rules="rules" :model="loginForm" label-width="80px" class="login-content-left-form">
            <el-form-item prop="username">
              <input v-model="loginForm.username" type="text" placeholder="请输入手机号/邮箱">
            </el-form-item>
            <el-form-item prop="password">
              <input v-model="loginForm.password" type="password" placeholder="请输入密码">
            </el-form-item>
            <el-form-item>
              <p>忘记密码?</p>
            </el-form-item>
            <el-form-item>
              <button @click.prevent="handleLogin">登&nbsp; &nbsp;入</button>
            </el-form-item>
          </el-form>
        </div>
        <div class="login-content-center" />

        <div class="login-content-right">
          <div class="login-content-right-head">
            <div>还没有账号：</div>
            <div><span><router-link to="register">马上注册<span class="el-icon-right" /></router-link></span>

            </div>
          </div>
          <div class="login-content-right-content">
            <div class="login-content-right-content-div1">使用以下账号直接登入</div>
            <div class="login-content-right-content-div2">
              <el-image>
                <div slot="error" class="image-slot">
                  <i class="el-icon-picture-outline" />
                </div>
              </el-image><el-image>
                <div slot="error" class="image-slot">
                  <i class="el-icon-picture-outline" />
                </div>
              </el-image><el-image>
                <div slot="error" class="image-slot">
                  <i class="el-icon-picture-outline" />
                </div>
              </el-image>
              <el-image>
                <div slot="error" class="image-slot">
                  <i class="el-icon-picture-outline" />
                </div>
              </el-image>
            </div>
          </div>

        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loginForm: {
        username: '',
        password: ''
      },
      rules: {
        username: { required: true, message: '请输入账号', trigger: 'blur' },
        password: { required: true, message: '请输入密码', trigger: 'blur' }
      }
    }
  },
  methods: {

    handleLogin() {
      this.$refs.loginForm.validate((valid) => {
        if (valid) {
          this.$store.dispatch('user/login', this.loginForm).then(res => {
            if (this.$route.query.redirect) {
              this.$router.push(this.$route.query.redirect)
            } else {
              this.$router.push('/home')
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.login{
  width: 100%;
  height: 35%;
  background-color: rgb(144,185,210);
  opacity:0.7;
  position: relative;
    .login-title{
      position: absolute;
      top: 40%;
      left: 20%;
      font-size: 20px;
    }
    .login-content{
      position: absolute;
      top: 60%;
      left: 25%;
      width: 50%;
        .login-content-card{
          padding-top:5px;
          padding-left: 5px;
        }
        .login-content-head{
          width: 60px;
          height: 60px;
          background-color: rgb(217,217,217);
          // border:100px solid;
          //  border-color:transparent transparent rgb(217,217,217) transparent;
        }
        .login-content-left{
          margin-left:-3%;
          width: 60%;

          .login-content-left-tabs{
            // margin: 0 auto;
            margin: 15px 15%;
            padding-bottom:5px;
            width: 80%;
            display:flex;
            align-items:center;
            justify-content:center;
             .login-content-left-tabs-pane{

              }
          }
          .login-content-left-form{
            width: 90%;
            input{
              margin-top:10px;
              outline: none;
              border: none;
              border-bottom: 1px solid  rgb(200,200,200);
              width: 100%;
              height: 30%;
              padding: 0 5px 4px 0;
              }
            p{
              margin: -7% 1% 0 0;
              position: absolute;
              right: 0;
              font-size: 12px;
            }
            button{
              margin:4% 0 40px 0;
              width: 100%;
              height: 40px;
              background-color: rgb(178,206,224);
              border: none;
              color: rgb(100,100,100);
              border-radius: 10px;

            }
          }
        }
          .login-content-center{
            position: absolute;
            left:60%;
            top: 8%;
            width: 1px;
            height: 86%;
            border: 1px dashed rgb(199,199,200);
        }
        .login-content-right{
          position: absolute;
          right: 0;
          width: 35%;
          top: 25%;
            .login-content-right-head{
              div{
                margin: 10px 10px;
              }
              span{
                font-size: 17px;
              }
            }
            .login-content-right-content{
              margin-top:25%;
              margin-left: 10px;
                .login-content-right-content-div2{
                  margin:10px 0px ;
                    .el-image{
                      width: 25px;
                      height: 20px;
                    }
                }
            }
        }

    }
}
</style>
